# response.text 是 requests 模块按照 chardet 模块推测出的编码字符集进行解码的结果
import requests

url = "https://www.baidu.com"
response = requests.get(url)

# # 手动设定编码格式
# response.encoding = 'utf-8'
# # 打印源码的str类型数据
# print(response.text)
#
# print(response.encoding)
#
# # response.context 是存储的bytes类型的响应源码，可以进行decode操作
# print(response.content)
# print(response.content.decode())



# 常见的响应对象参数和方法
# 响应url
print('-'*20, '响应url')
print(response.url)

# 状态码
print('-'*20, '状态码')
print(response.status_code)

# 响应对应的请求头
print('-'*20, '响应对应的请求头')
print(response.request.headers)

# 响应头
print('-'*20, '响应头')
print(response.headers)

# 打印响应设置cookie
print('-'*20, '打印响应设置cookie')
print(response.cookies)
